<?php
/*************************************************************************************
   Copyright notice

   This script uses some code parts of the glossary module for phpwcms (c) Oliver Georgi
   (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.

   This script uses some code parts from bmcatalog module
   (c) 2010 Benjamin Matzmorr, www.etype.de

   (c) 2012 webrealisierung gmbh, www.webrealisierung.ch
   Catalogue Module V 1.0.0  -  Date: 2012-06-01

   The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
   A copy is found in the textfile GPL.txt and important notices to the license
   from the author is found in LICENSE.txt distributed with these scripts.

   This script is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   PARTICULAR PURPOSE.  See the GNU General Public License for more details.

   This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------

	// delete
		$sql  = 'UPDATE '.DB_PREPEND.'phpwcms_mod_catalogue_catalog SET ';
		$sql .= "ctgc_status=9 WHERE ctgc_id=".$plugin['data']['ctgc_del'];
		_dbQuery($sql, 'UPDATE');
/*

following code (from calendar module) is not necessary though it would be cleaner
when a catalog is deleted, its id will remain in the entries c_catalogid
but the renderings in FE only take active catalogs (status=1)
next time entry or cp is updated the deleted catalog id will not be saved anymore

    //delete category in events
    $sql  = 'SELECT bmc_events_id, bmc_events_allcals FROM '.DB_PREPEND.'phpwcms_cmcalendar_events';
    $data = _dbQuery($sql);
		foreach($data as $value){
      if ($value['bmc_events_allcals']) {
        $value['bmc_events_allcals'] = explode('|',trim($value['bmc_events_allcals'], '|'));
    		$calarray = array();
        foreach($value['bmc_events_allcals'] as $val){
          if ($val != $plugin['data']['ctgc_del']) {
            array_push($calarray, $val);
          }
        }
       if (count($calarray)>0) {
       $value['bmc_events_allcals'] = '|'.implode('|', $calarray).'|';
       } else {
       $value['bmc_events_allcals'] = '';
       }
   
    	 $sql  = 'UPDATE '.DB_PREPEND.'phpwcms_cmcalendar_events SET ';
    	 $sql .= "bmc_events_allcals='".$value['bmc_events_allcals']."' WHERE bmc_events_id=".$value['bmc_events_id'];
    	 _dbQuery($sql, 'UPDATE');
      }
    }
*/
	  headerRedirect( ctg_map_url('controller=catalog', '') );
?>